import React, { useEffect, useState } from 'react'

function ThemeMode() {
    
    const [dark,setDark]=useState(()=>{
        const seved=localStorage.getItem('theme')
        return seved==='dark'||(!seved&&window.matchMedia('color').matches)
    })
    useEffect(()=>{
        document.documentElement.className=dark?"dark-theme":"light-theme"
        localStorage.setItem('theme',dark?"dark":"light")
    },[dark])
    
  return (
    <div >
        {/* <img src="../src/assets/imgs/night-model.svg" alt="" /> */}
      <button onClick={()=>setDark(!dark)} className='img'></button>
    </div>
  )
}

export default ThemeMode
